package xiyuan.view.distance;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;


public class AlgorithmEvaluator {
	public AlgorithmEvaluator(int size) throws IOException{
		File file = new File("distance.txt");
		FileWriter fw = new FileWriter(file);
		for (int i = 0; i < size; i++){
			String wordA = TongYiCi.getRandomWord(),
					wordB = TongYiCi.getRandomWord();
			int td = 0;//TongYiCi.getDistance(wordA, wordB);
			if (td == 46423){
				i--;
				continue;
			}
			double gd = GoogleDistance.getDistance(wordA, wordB);
			if (!Double.isInfinite(gd) && !Double.isNaN(gd)){
				fw.append(wordA+"\t"+wordB+"\t"+gd+"\t"+td+"\r\n");
				fw.flush();
			}
			System.out.println(wordA+"\t"+wordB+"\t"+gd+"\t"+td);
		}
		fw.close();
	}
	public static void main(String[] args){
		try {
			new AlgorithmEvaluator(100);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
